package win.smartown.app.weather.entity;

/**
 * Created by smartown on 2017/5/9 11:17.
 * Desc:
 */
public class Utils {

    public static String getSkycon(String skycon) {
        switch (skycon) {
            case "CLEAR_DAY":
            case "CLEAR_NIGHT":
                return "晴";
            case "PARTLY_CLOUDY_DAY":
            case "PARTLY_CLOUDY_NIGHT":
                return "多云";
            case "CLOUDY":
                return "阴";
            case "RAIN":
                return "雨";
            case "SNOW":
                return "雪";
            case "WIND":
                return "风";
            case "FOG":
                return "雾";
            case "HAZE":
                return "霾";
            case "SLEET":
                return "冻雨";
        }
        return "未知";
    }

    public static String formatTemp(double temp) {
        return (int) temp + "°";
    }

    public static String formatHumidity(double humidity) {
        return (int) (humidity * 100) + "%";
    }

    public static String getWindDirection(double direction) {
        if (direction < 0) {
            return "";
        }
        if (direction <= 11.25) {
            return "北";
        }
        if (direction <= 33.75) {
            return "北东北";
        }
        if (direction <= 56.25) {
            return "东北";
        }
        if (direction <= 78.75) {
            return "东东北";
        }
        if (direction <= 101.25) {
            return "东";
        }
        if (direction <= 123.75) {
            return "东东南";
        }
        if (direction <= 146.25) {
            return "东南";
        }
        if (direction <= 168.75) {
            return "南东南";
        }
        if (direction <= 191.25) {
            return "南";
        }
        if (direction <= 213.75) {
            return "南西南";
        }
        if (direction <= 236.25) {
            return "南";
        }
        if (direction <= 258.75) {
            return "西西南";
        }
        if (direction <= 281.25) {
            return "西";
        }
        if (direction <= 303.75) {
            return "西西北";
        }
        if (direction <= 326.25) {
            return "西北";
        }
        if (direction <= 348.75) {
            return "北西北";
        }
        if (direction <= 360) {
            return "北";
        }
        return "";
    }

    public static String getWindLevel(double speed) {
        if (speed <= 0.2) {
            return "无风";
        }
        if (speed <= 1.5) {
            return "软风";
        }
        if (speed < 3.3) {
            return "轻风";
        }
        if (speed < 5.4) {
            return "微风";
        }
        if (speed < 7.9) {
            return "和风";
        }
        if (speed < 10.7) {
            return "轻劲风";
        }
        if (speed < 13.8) {
            return "强风";
        }
        if (speed < 17.1) {
            return "疾风";
        }
        if (speed < 20.7) {
            return "大风";
        }
        if (speed < 24.4) {
            return "烈风";
        }
        if (speed < 28.4) {
            return "狂风";
        }
        if (speed < 32.6) {
            return "暴风";
        }
        if (speed < 36.9) {
            return "台风";
        }
        return "外星风";
    }

}
